package cn.yusei.teamTribe.util;

import java.util.Random;

public class RandomCodeUtil {
    private static final String string = "123456789";
    private static Random rand = new Random();
    private static final int DEFAULT_LENGTH = 6;

    public static String getCode()
    {
        return getCode(DEFAULT_LENGTH);
    }

    public static String getCode(int length)
    {
        char[] ch = new char[length];
        for(int i=0; i<length; i++)
        {
            ch[i] = string.charAt(rand.nextInt(string.length()));
        }
        return new String(ch);
    }

}
